package main

import "fmt"

// 给字符串表达式，计算

// 逆波兰表达式

func calculate(s string) int {
	sk := []int{}
	preSign := '+'
	num := 0
	for i, ch := range s {
		isDigit := ch >= '0' && ch <= '9'
		if isDigit {
			num = num*10 + int(ch-'0')
		}
		if !isDigit && ch != ' ' || i == len(s)-1 {
			switch preSign {
			case '+':
				sk = append(sk, num)
			case '-':
				sk = append(sk, -num)
			case '*':
				sk[len(sk)-1] *= num
			case '/':
				sk[len(sk)-1] /= num
			}
			preSign = ch
			num = 0
		}
	}
	var res int
	for _, v := range sk {
		res += v
	}
	return res
}

func main() {
	s := "3+2*2"
	res := calculate(s)
	fmt.Println(res)
}
